# frozen_string_literal: true

class RuleEntitiesController < ApplicationController
  def fire
    @results = RuleEntityService.fire(params.required(:id), inputs: params.required(:inputs).permit!)

    respond_to do |format|
      format.js
      format.json { render json: @results }
    end
  end

  def validate
    @result = RuleEntityService.validate(params.required(:id))

    respond_to do |format|
      format.js
      format.json { render json: @result }
    end
  end

  def deploy
    @result = RuleEntityService.deploy(params.required(:id))

    respond_to do |format|
      format.js
      format.json { render json: @result }
    end
  end
end
